THRIFT-6049: Limit struct read/write recursion depth in Lua library#3554
Open
Jens-G wants to merge 1 commit into
Open
THRIFT-6049: Limit struct read/write recursion depth in Lua library#3554Jens-G wants to merge 1 commit into
Jens-G wants to merge 1 commit into
Conversation
bca5d0d to
11920a3
Compare
11920a3 to
351cf16
Compare
Client: lua The Lua generator wraps each generated read()/write() body with incrementRecursionDepth()/pcall/decrementRecursionDepth() on TProtocolBase (limit DEFAULT_RECURSION_DEPTH = 64, TProtocolException.DEPTH_LIMIT on excess). Previously only skip() was bounded, so the generated read/write path recursed without limit. Unions and exceptions are generated through the same path, so they are bounded too. Replace the isolated counter test with a generated-code round-trip (lib/lua/test/test_recursion_depth.lua) over a recursive struct (RecTree), union (RecUnion) and exception (RecError) from a new RecursionDepth.thrift, driven through the generated read()/write() over a real TBinaryProtocol: a chain at the limit round-trips (also proving the guard does not double-count), a chain past it is rejected on write, and a hand-serialized over-limit payload is rejected on read (crafted with the real recursive field, id 1 = list<self>, so the reader recurses through the guarded path rather than the separate, unbounded skip()). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
351cf16 to
07e7c38
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
THRIFT-6049: Limit struct read/write recursion depth in the Lua library
Change
The Lua generator wraps each generated
read()/write()body withincrementRecursionDepth()/pcall/decrementRecursionDepth()onTProtocolBase(limitDEFAULT_RECURSION_DEPTH= 64,TProtocolException.DEPTH_LIMITon excess). Previously onlyskip()was bounded. Unions and exceptions are generated through the same path, so they are bounded too.Test
Replaces the isolated counter test with a generated-code round-trip (
lib/lua/test/test_recursion_depth.lua) over a recursive struct (RecTree), union (RecUnion) and exception (RecError) from a newRecursionDepth.thrift, driven through the generatedread()/write()on a realTBinaryProtocol. For each of the three kinds:list<self>) so the reader recurses through the guarded path rather than the separate, unboundedskip().Validated locally with Lua 5.4: 21/21 pass. No functional Lua CI (
--without-lua); the only CI surface touched is the C++compilerbuild (generator edit).skip()stays separately bounded.🤖 Generated with Claude Code